package com.it.base.common.view;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonView;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@ApiModel(value = "PageResult", description = "返回值分页对象")
public class PageResult<T> implements Serializable {
	
	private static final long serialVersionUID = 1L;

	// 基础视图
	public interface PageRView {
	};
	
	/**
	 * 总条数
	 */
	@JsonView(PageRView.class)
	@ApiModelProperty(name = "total", value = "总条数", dataType = "long")
	public long total = Long.valueOf(0);// total

	/**
	 * 数据
	 */
	@JsonView(PageRView.class)
	@ApiModelProperty(name = "rows", value = "数据", dataType = "List")
	public List<T> rows = Collections.emptyList();

	public PageResult(long total, List<T> data) {
		this.total = total;
		this.rows = data;
	}
}
